package com.atguigu.homework.exer2;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/14 17:07
 * @注释
 */
public class Test {
    public static void main(String[] args) {
        Bird p = new Penguin();
        Bird s = new Swan();
        Bird c = new Chicken();

        Bird[] birds = {p, s, c};

        for (int i = 0; i < birds.length; i++) {
            birds[i].eat();
            if (birds[i] instanceof Flyable) {
                Flyable f = (Flyable) birds[i];
                f.fly();
            }
            if (birds[i] instanceof Swimming) {
                Swimming sw = (Swimming) birds[i];
                sw.swim();
            }
        }
    }
}
